chore(deps): update marked to v18 - #603
Merged
Merged
Conversation
Bump marked from ^17.0.1 to ^18.0.11. marked v18 no longer folds a block token's trailing blank line(s) into its own raw; that whitespace now surfaces as a separate space token immediately after the block (html/heading/table, etc.). This broke parseMarkdownIntoBlocks, which relied on trailing blank lines being absorbed into html blocks: a dangling space token after a closed custom-tag HTML block was emitted as its own standalone block instead of being merged. Fix parseMarkdownIntoBlocks to fold a space token into the previous block instead of pushing it as a new block, restoring v17-identical block boundaries/counts. The lossless token.raw concatenation invariant is preserved. Added a regression test for the v18 tokenization shape. TypeScript 5.9.3 typechecks cleanly against marked@18's .d.ts despite marked's internal TS bump to v6, so no TS upgrade is required. All 1145 tests pass. Closes vercel#566
Contributor
|
@sleitor is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #566
Bumps
markedfrom^17.0.1to^18.0.11(latest) inpackages/streamdown/package.json.Breaking change in marked v18
marked v18 no longer absorbs a block token's trailing blank line(s) into its own
raw. That whitespace now surfaces as a separatespacetoken immediately following the block (observed onhtml,heading, andtableblock tokens).Example, for
<ai-thinking>\n\n**bold**\n\n</ai-thinking>\n\n# Outside:html('<ai-thinking>\n\n'),paragraph('**bold**'),space('\n\n'),html('</ai-thinking>\n\n'),heading('# Outside')html('<ai-thinking>'),space('\n\n'),paragraph('**bold**'),space('\n\n'),html('</ai-thinking>'),space('\n\n'),heading('# Outside')The
token.rawlossless concatenation invariant still holds (joining allrawvalues still reconstructs the source exactly) — the difference is purely in how the whitespace is bucketed into tokens.Fix
parseMarkdownIntoBlocks(packages/streamdown/lib/parse-blocks.tsx) tracks anhtmlStackto merge tokens between a custom tag's opening and closing HTML block tokens into one block. Under v17, the closing tag's trailing blank line was absorbed into that samehtmltoken, so it was included in the merge before the stack was popped. Under v18, that blank line is a separatespacetoken emitted after the closing tag pops the stack, so it fell through and got pushed as its own standalone block — turning what should be 2 blocks into 3.Since a bare
spacetoken is never meaningful content on its own, the fix folds anyspacetoken into the previous block (when one exists) instead of pushing it as a new block:This restores block boundaries/counts identical to v17 output, for both the htmlStack-merge path and the general case. The existing math-block merge logic (
$$odd-count tracking) andpreviousTokenWasCodetracking are untouched and placed after this check.A regression test was added in
__tests__/custom-tag-markdown.test.tsxasserting the v18 tokenization shape doesn't create an extra block and thatblocks.join("") === input(lossless invariant).TypeScript
marked v18's internal TS toolchain bumped to v6, but this is not a consumer-facing constraint — TypeScript 5.9.3 (what this repo pins) typechecks cleanly against marked@18's
.d.tswithskipLibCheck: false. No TS upgrade needed.Tests
pnpm testinpackages/streamdown: all 1145 tests pass (1144 pre-existing + 1 new regression test), 84 test files.Changeset
Added
.changeset/update-marked-v18.mdas apatchfor thestreamdownpackage (dependency bump + internal parser fix, no public API change).